//
//  TcpServerUtil.h
//  TestTcpUdp
//
//  Created by leeson zhong on 2021/7/6.
//

#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

@protocol TcpServerUtilDelegate
@optional
-(void)onTcpServerAcceptClient:(BOOL)flag ClientIp:(NSString *)clientIp ClientPort:(int)clientPort;
-(void)onTcpServerReceiveData:(NSData *)data ClientIp:(NSString *)clientIp ClientPort:(int)clientPort;
-(void)onTcpServerClose;

@end


@interface TcpServerUtil : NSObject

@property (nonatomic,weak) id<TcpServerUtilDelegate> delegate;

-(BOOL)initWithServerPort:(int)port;
-(BOOL)sendData:(NSData *)data;
-(void)close;

-(int)getServerPort;
-(NSString *)getClientIp;
-(int)getClientPort;

@end

NS_ASSUME_NONNULL_END
